package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.CustomerDao;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerDao customerDao;

    @Override
    public Integer count() {
        return customerDao.count();
    }

    @Override
    public List<Customer> list(Integer page, Integer rows, String customerName) {
        return customerDao.list(page, rows, customerName);
    }

    @Override
    public Boolean save(Customer  customer) {
        if (customer.getCustomerId() != null && customer.getCustomerId() != 0) {
            // 添加
            return customerDao.save(customer);
        } else {
            // 修改
            return customerDao.updateById(customer);
        }
    }

    @Override
    public Boolean delete(String ids) {
        return customerDao.deleteById(ids);
    }
}
